<template>
  <div class="Car">
    <div
      class="content"
      @click="toCarDetail(item)"
      v-for="item in data"
      :key="item.concern_id"
    >
      <div class="left">
        <img :src="item.cover_image" alt="" />
      </div>
      <div class="right">
        <p class="name">{{ item.series_name }}</p>
        <p class="score">{{ item.car_name }}</p>
        <p class="price">价格:{{ item.price }}</p>
        <p class="year">年份: {{  item.year }}</p>
        <p class="right"><span>问底价</span></p>
      </div>
    </div>
  </div>
</template>

<script>
import { reactive, toRefs } from "vue";
import { useRouter } from "vue-router";
export default {
  name: "sameCar",
  props: {
    sameCar: {
      type: Object,
      default: {},
    },
  },
  setup(props, { emit }) {
    const state = reactive({
      data: [],
    });
    const router = useRouter();
    state.data = props.sameCar;
    const toCarDetail = (item) => {
      router.replace(`/carDetail/${item.series_id}`);
      emit("refreshCar", item.series_id);
    };
    return {
      ...toRefs(state),
      toCarDetail,
    };
  },
};
</script>

<style lang='less' scoped>
p {
  margin: 0;
}
.Car {
  height: calc(100vh - 350px);
  overflow-y: scroll;
  padding: 0 10px;
  box-sizing: border-box;
  .content {
    position: relative;
    background: #efefef;
    border: 1px solid #ebeef5;
    box-shadow: 0 2px 12px 0 rgb(0 0 0 / 25%);
    display: flex;
    width: 100%;
    padding: 0 10px;
    margin: 10px auto;
    border-radius: 10px;
    width: 100%;
    box-sizing: border-box;
    .left {
      flex: 0 0 120px;
      p {
        font-size: 12px;
      }
      img {
        width: 90%;
      }
    }
    .right {
      flex: 1;
      text-align: left;
      .name {
        font-size: 18px;
        font-weight: 900;
        line-height: 22px;
      }
      .score {
        width: calc(100% - 80px);
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-size: 12px;
        line-height: 16px;
      }
      .price {
        color: #dad;
        font-size: 16px;
        line-height: 18px;
      }
      .year {
        font-size: 12px;
        line-height: 16px;
      }
      .right {
        border-radius: 5px;
        position: absolute;
        right: 20px;
        top: 15px;
        line-height: 22px;
        font-size: 16px;
        background: linear-gradient(
          rgba(255, 233, 200, 0.3),
          rgba(255, 130, 100, 0.1)
        );
        padding: 5px;
      }
    }
  }
}
</style>